<!--
 * Description: 报价commodity新增页面
 * Company: 联宝（合肥）电子科技有限公司
 * Author: Dongxu.Ni
 * Date: 2020/04/14 02:52
-->

<template>
  <div>
    <!--数据表单-->
    <el-form label-width="80px" :model="formData" size="mini">
      <el-row>
        <el-col :span="12">
          <!--名称-->
          <el-form-item :label="$t('Commodity.name')">
            <el-input v-model="formData.name" v-blur:name="formData" clearable />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <!--GCM功能-->
          <el-form-item :label="$t('Commodity.gcmFunction')">
            <el-select
              v-model="formData.gcmFunction"
              clearable
              :placeholder="$t('select.placeholder')"
              style="width: 100%"
            >
              <el-option
                v-for="item in $store.getters['enums/getGcmFunctionListOnly']"
                :key="item"
                :label="item"
                :value="item"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <!--rate-->
          <el-form-item :label="$t('Commodity.rate')">
            <el-input v-model="formData.rate" v-blur:rate="formData" clearable type="number" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <!--描述-->
          <el-form-item :label="$t('Commodity.desc')">
            <el-input v-model="formData.desc" v-blur:desc="formData" clearable />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <span style="display: block;text-align: center;margin-top: 5px">
      <!--取消按钮-->
      <el-button size="medium" @click="cancel">{{ $t('button.cancel') }}</el-button>
      <!--保存按钮-->
      <el-button size="medium" type="primary" @click="save">{{ $t('button.save') }}</el-button>
    </span>
  </div>
</template>

<script>
import { commodityAdd } from '@/api/quote/commodity'

export default {
  name: 'CommodityAdd',
  props: {},
  data() {
    return {
      formData: {}
    }
  },

  methods: {
    save() {
      commodityAdd(this.formData).then(() => {
        this.$emit('save')
      })
    },
    cancel() {
      this.$emit('cancel')
    }
  }
}
</script>
